package com.liuning.graduationdemo.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liuning.graduationdemo.entity.Order;
import com.liuning.graduationdemo.entity.User;
import com.liuning.graduationdemo.mapper.OrderMapper;
import com.liuning.graduationdemo.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuning.graduationdemo.utils.TokenUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pumpkin
 * @since 2022-04-25
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    public int updateState(String tradeNo, int state, String gmtPayment) {
        return orderMapper.updateState(tradeNo,state,gmtPayment);
    }

    @Override
    public Page<Order> findPatientPage(Page<Order> page, String nickname) {
        User currentUser = TokenUtils.getCurrentUser();

        return orderMapper.findPatientPage(page,nickname,currentUser.getId());
    }
}
